<!-- 用户编辑模态框 -->
<style>
    #companyRate-table {
        width: 100%;
    }

    #companyRate-table tr {
        width: 100%;
    }

    /*#companyRate-table .companyRate-input {*/
    /*width: 22%;*/
    /*}*/

    .companyRate-click i:hover {
        cursor: pointer;
        color: #ff5713;
    }
</style>
<div class="modal-body">
    <form class="form-horizontal" method="post" name="form_submit" id="form_submit"
          action="${request.contextPath}/soa/baseinfo/customer/datas/save">
        <input type="hidden" id="id" name="id" value="${model.id!}">
        <div class="box-body">
            <div class="form-group">
                <label for="companyName" class="col-sm-3 control-label">公司名称</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="companyName" name="companyName" placeholder="请输入"
                           value="${model.companyName!}">
                </div>
            </div>
            <div class="form-group">
                <label for="companyCode" class="col-sm-3 control-label">统一社会信用代码</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="companyCode" name="companyCode" placeholder="请输入"
                           value="${model.companyCode!}">
                </div>
            </div>
            <div class="form-group">
                <label for="companyType" class="col-sm-3 control-label">公司类型</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="companyType" name="companyType" placeholder="请输入"
                           value="${model.companyType!}">
                </div>
            </div>
            <div class="form-group">
                <label for="companyCapital" class="col-sm-3 control-label">注册资本</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="companyCapital" name="companyCapital" placeholder="请输入"
                           value="${model.companyCapital!}">
                </div>
            </div>
            <div class="form-group">
                <label for="companyLegal" class="col-sm-3 control-label">法定代表人</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="companyLegal" name="companyLegal" placeholder="请输入"
                           value="${model.companyLegal!}">
                </div>
            </div>
            <div class="form-group">
                <label for="companyCreateTime" class="col-sm-3 control-label">成立时间</label>
                <div class="col-sm-6 input-group">
                    <span style="position: relative; z-index: 1080;">
                    <input style="margin-left: 15px !important;" type="text" class="form_datetime form-control" id="companyCreateTime" name="companyCreateTime"
                           placeholder="请输入"
                           value="${model.companyCreateTime!}" readonly></span>
                    <span class="input-group-addon">
                      	<i style="margin-left: 15px !important;"  class="fa fa-calendar"></i>
                      </span>
                </div>
            </div>
            <div class="form-group">
                <label for="companyContact" class="col-sm-3 control-label">联系人</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="companyContact" name="companyContact" placeholder="请输入"
                           value="${model.companyContact!}">
                </div>
            </div>
            <div class="form-group">
                <label for="companyContactPhone" class="col-sm-3 control-label">联系电话</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="companyContactPhone" name="companyContactPhone"
                           placeholder="请输入"
                           value="${model.companyContactPhone!}">
                </div>
            </div>
            <div class="form-group">
                <label for="companyAddress" class="col-sm-3 control-label">办公地址</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" id="companyAddress" name="companyAddress" placeholder="请输入"
                           value="${model.companyAddress!}">
                </div>
            </div>
            <input type="hidden" class="form-control" id="companyRate" name="companyRate" placeholder="请输入"
                   value="${model.companyRate!}">
            <div class="form-group">
                <label for="companyRate-table" class="col-sm-3 control-label">股东构成</label>
                <div class="col-sm-9">
                    <table id="companyRate-table">
                        <tbody>
                        <tr>
                            <td><input type="text" class="form-control companyRate-input companyRateName"
                                       placeholder="股东名称"/></td>
                            <td><input style="margin-left: 10px;" type="text"
                                       class="form-control companyRate-input companyRateValue" placeholder="股东占股"/></td>
                            <td class="companyRate-click plus"><i style="margin-left: 20px;" class="fa fa-plus"></i>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <!--<div class="form-group">-->
                <!--<label for="companyAddress" class="col-sm-3 control-label">上传附件</label>-->
                <!--<div class="col-sm-9">-->
                    <!--<input type="file" id="file1" /><br />-->
                    <!--上传进度:<progress id="pro" value="0"></progress>-->
                    <!--<div id="result"></div>-->
                    <!--<input type="button" value="读取二进制文件" onclick="readBinary();" /><br />-->
                <!--</div>-->
            <!--</div>-->
        </div>
    </form>
    <!--<form class="form-horizontal" id="form1" enctype="multipart/form-data" method="post" action="Upload.aspx">-->
        <!--<div class="form-group">-->
            <!--<label for="fileToUpload" class="col-sm-3 control-label">附件</label>-->
            <!--<div class="col-sm-9">-->
                <!--<input type="file" name="fileToUpload" id="fileToUpload" onchange="fileSelected();"/>-->
            <!--</div>-->
        <!--</div>-->

    <!--</form>-->
    <!--<div class="form-group">-->
        <!--<label for="fileName" class="col-sm-3 control-label"></label>-->
        <!--<div class="col-sm-9">-->
            <!--<div id="fileName"></div>-->
            <!--<div id="fileSize"></div>-->
            <!--<div id="fileType"></div>-->
            <!--<div class="row">-->
                <!--<input type="button" onclick="uploadFile()" value="Upload" />-->
            <!--</div>-->
            <!--<div id="progressNumber"></div>-->
        <!--</div>-->
    <!--</div>-->
</div>
<script type="text/javascript">
    function fileSelected() {
        var file = document.getElementById('fileToUpload').files[0];
        if (file) {
            var fileSize = 0;
            if (file.size > 1024 * 1024)
                fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB';
            else
                fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB';

            document.getElementById('fileName').innerHTML = 'Name: ' + file.name;
            document.getElementById('fileSize').innerHTML = 'Size: ' + fileSize;
            document.getElementById('fileType').innerHTML = 'Type: ' + file.type;
        }
        uploadFile();
    }

    function uploadFile() {
        var fd = new FormData();
        fd.append("fileToUpload", document.getElementById('fileToUpload').files[0]);
        var xhr = new XMLHttpRequest();
        xhr.upload.addEventListener("progress", uploadProgress, false);
        xhr.addEventListener("load", uploadComplete, false);
        xhr.addEventListener("error", uploadFailed, false);
        xhr.addEventListener("abort", uploadCanceled, false);
        xhr.open("POST", "UploadMinimal.aspx");
        xhr.send(fd);
    }

    function uploadProgress(evt) {
        if (evt.lengthComputable) {
            var percentComplete = Math.round(evt.loaded * 100 / evt.total);
            document.getElementById('progressNumber').innerHTML = percentComplete.toString() + '%';
        }
        else {
            document.getElementById('progressNumber').innerHTML = '无法计算';
        }
    }

    function uploadComplete(evt) {
        /* 当服务器响应后，这个事件就会被触发 */
        alert(evt.target.responseText);
    }

    function uploadFailed(evt) {
        alert("上传文件发生了错误尝试");
    }

    function uploadCanceled(evt) {
        alert("上传被用户取消或者浏览器断开连接");
    }
</script>
<script type="text/javascript">
//    var reader=null;
//    if(FileReader){
//        reader=new FileReader();
//    }else{
//        alert("ERROR!");
//    }
//    var readBinary=function(){
//        reader.readAsBinaryString(document.getElementById("file1").files[0]);
//        var pro=document.getElementById("pro");
//        pro.max=document.getElementById("file1").files[0].size;
//        reader.onprogress=function(evt){
//            pro.value=evt.loaded;
//        }
//    };
    //表单校验及提交事件
    $('#form_submit').bootstrapValidator({
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            companyName: {
                message: 'this is not valid',
                validators: {
                    notEmpty: {
                        message: '不能为空！'
                    }
                }
            }
            , companyCode: {
                message: 'this is not valid',
                validators: {
                    notEmpty: {
                        message: '不能为空！'
                    }
                }
            }
            , companyType: {
                message: 'this is not valid',
                validators: {
                    notEmpty: {
                        message: '不能为空！'
                    }
                }
            }
            , companyCapital: {
                message: 'this is not valid',
                validators: {
                    notEmpty: {
                        message: '不能为空！'
                    }
                }
            }
            , companyContact: {
                message: 'this is not valid',
                validators: {
                    notEmpty: {
                        message: '不能为空！'
                    }
                }
            }
            , companyContactPhone: {
                message: 'this is not valid',
                validators: {
                    notEmpty: {
                        message: '不能为空！'
                    }
                }
            }
            , companyAddress: {
                message: 'this is not valid',
                validators: {
                    notEmpty: {
                        message: '不能为空！'
                    }
                }
            }
        }
    });
    function createTr() {
        var tr = '<tr style="margin-bottom: 10px !important;">' +
                '<td><input style="margin-bottom: 10px" type="text" class="form-control companyRate-input companyRateName" placeholder="股东名称"/></td>' +
                '<td><input style="margin-bottom: 10px;margin-left: 10px;" type="text" class="form-control companyRate-input companyRateValue" placeholder="股东占股" /></td>' +
                '<td class="companyRate-click remove"><i style="margin-left: 20px;" class="fa fa-remove"></i></td>' +
                '</tr>';
        return tr;
    }
    $(document).ready(function () {
        //加载时间控件
        $('.form_datetime').datepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            weekStart: 1,
            autoclose: true,
            forceParse: false
        });
        $('#companyRate-table').on('click', 'tbody .plus', function (e) {
            var tr = createTr();
            $(this).parent().before(tr);
        });
        $('#companyRate-table').on('click', 'tbody .remove', function (e) {
            $(this).parent().remove();
        });
    });
</script>
